package com.itheima.mapper;

import com.itheima.pojo.Book;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    List<Book> pageHelper(String name, String author, String press);

    @Insert("insert into cl_book (name,author,press,price,create_time,update_Time)" +
            "values " +
            "(#{name},#{author},#{press},#{price},#{createTime},#{updateTime})")
    void insert(Book book);

    void update(Book book);

    @Select("select * from cl_book where id = #{id}")
    Book getById(Integer id);

    void delete(List<Integer> ids);
    //借阅图书，减少图书库存
    @Update("update cl_book set number = number - 1 where id = #{bookId}")
    void reduceNum(Integer bookId);

    //归还图书，增加图书库存
    @Update("update cl_book set number = number + 1 where id = #{bookId}")
    void addNum(Integer bookId);
}
